package com.joshua.spring.exception;

import com.joshua.spring.entity.vo.GlobalResponse;
import com.joshua.spring.util.JacksonUtils;
import com.netflix.hystrix.exception.HystrixBadRequestException;
import lombok.Data;
import lombok.extern.slf4j.Slf4j;

/**
 * projectName dragon-cloud
 * package com.joshua.spring.exception
 * classname  InnerServiceException
 * <p>
 * description 内部调用异常 继承 {@link HystrixBadRequestException}
 * 不会走熔断，会向上游服务抛出此异常
 * </p>
 *
 * @author <a href="mailto:joshualwork@163.com">joshua_liu</a>
 * @date 2020/8/29 16:29
 */
@Data
@Slf4j
public class InnerServiceException extends HystrixBadRequestException {
    private GlobalResponse globalResponse;

    InnerServiceException(GlobalResponse globalResponse) {
        super(JacksonUtils.obj2json(globalResponse));
        this.globalResponse = globalResponse;
    }

    @Override
    public String getMessage() {
        return JacksonUtils.obj2json(globalResponse);
    }

    @Override
    public String toString() {
        return globalResponse.toString();
    }
}
